// DlgTCP.cpp : implementation file
//

#include "stdafx.h"
#include "sfileservery.h"
#include "DlgTCP.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDlgTCP dialog


CDlgTCP::CDlgTCP(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgTCP::IDD, pParent)
{
	m_TcpNomalDlg=NULL;
	m_TcpSelectDlg=NULL;
	m_ArrayDlg.RemoveAll();
}
CDlgTCP::~CDlgTCP()
{
	m_ArrayDlg.RemoveAll();
	delete m_TcpNomalDlg;
	m_TcpNomalDlg=NULL;
	delete m_TcpSelectDlg;
	m_TcpSelectDlg=NULL;
}

void CDlgTCP::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgTCP)
	DDX_Control(pDX, IDC_BTN_TCP_COMPLETION, m_btncompletion);
	DDX_Control(pDX, IDC_BTN_TCP_NORMAL, m_btnnomarl);
	DDX_Control(pDX, IDC_BTN_TCP_OVER, m_btnover);
	DDX_Control(pDX, IDC_BTN_TCP_OVERLEPPD, m_btnoverleppd);
	DDX_Control(pDX, IDC_BTN_TCP_SELECT, m_btnselect);
	DDX_Control(pDX, IDC_BTN_TCP_WSAEVENT, m_btnWsaEvent);
	DDX_Control(pDX, IDC_BTN_TCP_WSASelect, m_btnWSAselect);
	DDX_Control(pDX, IDC_STATIC_GROUP, m_Group);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgTCP, CDialog)
	//{{AFX_MSG_MAP(CDlgTCP)
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgTCP message handlers

BOOL CDlgTCP::OnInitDialog() 
{
	CDialog::OnInitDialog();
	m_TcpNomalDlg=new CTCPNormalDlg();
	m_TcpNomalDlg->Create(IDD_DLG_TCP_NORMAL,this);
	m_TcpSelectDlg=new CTCPSelectDlg();
	m_TcpSelectDlg->Create(IDD_DLG_TCP_SELECT,this);
	m_ArrayDlg.Add(m_TcpNomalDlg);
	m_ArrayDlg.Add(m_TcpSelectDlg);
	ShowWindows(m_TcpNomalDlg);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgTCP::ShowWindows( CDialog *pThis )
{
	for (int i=0;i<m_ArrayDlg.GetSize();i++)
	{
		if (m_ArrayDlg[i]==pThis)
		{
			m_ArrayDlg[i]->ShowWindow(SW_SHOW);
		}
		else
		{
			m_ArrayDlg[i]->ShowWindow(SW_HIDE);
		}
	}
}
void CDlgTCP::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);	
	if (m_Group.GetSafeHwnd()==NULL)
	{
		return;
	}
 	m_Group.SetWindowPos(&wndBottom,0,0,130,cy,NULL);
 	m_btnnomarl.SetWindowPos(&wndBottom,15,20,100,40,NULL);
 	m_btnselect.SetWindowPos(&wndBottom,15,20+50,100,40,NULL);
 	m_btnWSAselect.SetWindowPos(&wndBottom,15,20+100,100,40,NULL);
 	m_btnWsaEvent.SetWindowPos(&wndBottom,15,20+150,100,40,NULL);
 	m_btnoverleppd.SetWindowPos(&wndBottom,15,20+200,100,40,NULL);
 	m_btnover.SetWindowPos(&wndBottom,15,20+250,100,40,NULL);
 	m_btncompletion.SetWindowPos(&wndBottom,15,20+300,100,40,NULL);
 	for (int i=0;i<m_ArrayDlg.GetSize();i++)
 	{
 		m_ArrayDlg[i]->SetWindowPos(&wndBottom,130,0,cx-130,cy,NULL);
 	}
}
